package com.course.server.util;


import com.course.server.domain.Member;
import org.springframework.stereotype.Component;

/**
 * 持有用户信息,用于代替session对象.
 * session对象可以直接持有数据，并且是线程隔离的
 */
@Component
public class HostHolder {

    private ThreadLocal<Member> members = new ThreadLocal<>();//以线程为key存取值

    public void setMember(Member member) {
        members.set(member);
    }

    public Member getMember() {
        return members.get();
    }

    public void clear() {
        members.remove();
    }

}
